home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / ASTRONOM / H139.ZIP / UI101.ZIP / IO / KB / KB_TEST.C < prev    next >
C/C++ Source or Header  |  1991-11-04  |  3KB  |  128 lines

  1. /*************************************************************************
  2.  
  3.     kb_test.c    Test Keyboard (KB) Subroutines
  4.             for Bywater Software
  5.  
  6.             Copyright (c) 1991, Ted A. Campbell
  7.  
  8.             Bywater Software
  9.             P. O. Box 4023 
  10.             Duke Station 
  11.             Durham, NC  27706
  12.  
  13.             email: tcamp@hercules.acpub.duke.edu
  14.  
  15.     Copyright and Permissions Information:
  16.  
  17.     All U.S. and international copyrights are claimed by the
  18.     author. The author grants permission to use this code
  19.     and software based on it under the following conditions:
  20.     (a) in general, the code and software based upon it may be 
  21.     used by individuals and by non-profit organizations; (b) it
  22.     may also be utilized by governmental agencies in any country,
  23.     with the exception of military agencies; (c) the code and/or
  24.     software based upon it may not be sold for a profit without
  25.     an explicit and specific permission from the author, except
  26.     that a minimal fee may be charged for media on which it is
  27.     copied, and for copying and handling; (d) the code must be 
  28.     distributed in the form in which it has been released by the
  29.     author; and (e) the code and software based upon it may not 
  30.     be used for illegal activities. 
  31.  
  32. **************************************************************************/
  33.  
  34. #include "stdio.h"
  35. #include "kb.h"
  36.  
  37. #define ESC     0x1b
  38.  
  39. main()
  40.     {
  41.     unsigned c;
  42.     kb_init();
  43.  
  44.     printf( "Test of KB functions. \n" );
  45.     printf( "Press ESCAPE to exit. \n" );
  46.  
  47.     c = 0;
  48.     while( c != ESC )
  49.         {
  50.         c = kb_rx();
  51.         switch ( c )
  52.             {
  53.             case KB_LEFT:
  54.                 printf( "Key:\tLEFT \n" );
  55.                 break;
  56.             case KB_RIGHT:
  57.                 printf( "Key:\tRIGHT \n" );
  58.                 break;
  59.             case KB_UP:
  60.                 printf( "Key:\tUP \n" );
  61.                 break;
  62.             case KB_DOWN:
  63.                 printf( "Key:\tDOWN \n" );
  64.                 break;
  65.             case KB_HOME:
  66.                 printf( "Key:\tHOME \n" );
  67.                 break;
  68.             case KB_END:
  69.                 printf( "Key:\tEND \n" );
  70.                 break;
  71.             case KB_P_UP:
  72.                 printf( "Key:\tPAGE UP \n" );
  73.                 break;
  74.             case KB_P_DOWN:
  75.                 printf( "Key:\tPAGE DOWN \n" );
  76.                 break;
  77.             case KB_INSERT:
  78.                 printf( "Key:\tINSERT \n" );
  79.                 break;
  80.             case KB_DELETE:
  81.                 printf( "Key:\tDELETE \n" );
  82.                 break;
  83.             case KB_FK0:
  84.                 printf( "Key:\tFK 10 \n" );
  85.                 break;
  86.             case KB_FK1:
  87.                 printf( "Key:\tFK 1 \n" );
  88.                 break;
  89.             case KB_FK2:
  90.                 printf( "Key:\tFK 2 \n" );
  91.                 break;
  92.             case KB_FK3:
  93.                 printf( "Key:\tFK 3 \n" );
  94.                 break;
  95.             case KB_FK4:
  96.                 printf( "Key:\tFK 4 \n" );
  97.                 break;
  98.             case KB_FK5:
  99.                 printf( "Key:\tFK 5 \n" );
  100.                 break;
  101.             case KB_FK6:
  102.                 printf( "Key:\tFK 6 \n" );
  103.                 break;
  104.             case KB_FK7:
  105.                 printf( "Key:\tFK 7 \n" );
  106.                 break;
  107.             case KB_FK8:
  108.                 printf( "Key:\tFK 8 \n" );
  109.                 break;
  110.             case KB_FK9:
  111.                 printf( "Key:\tFK 9 \n" );
  112.                 break;
  113.             default:
  114.                 if ( ( c & KB_ALT ) == 0 )
  115.                     {
  116.                     printf( "Key:\t%c \n", c );
  117.                     }
  118.                 else
  119.                     {
  120.                     printf( "Key:\tALT-%c \n", ( c & 127 ));
  121.                     }
  122.                 break;
  123.             }
  124.         }
  125.     kb_deinit();
  126.     }
  127.  
  128.